# Scrapy settings for crawl_jd project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
#     https://docs.scrapy.org/en/latest/topics/settings.html
#     https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
#     https://docs.scrapy.org/en/latest/topics/spider-middleware.html

BOT_NAME = 'crawl_jd'

SPIDER_MODULES = ['crawl_jd.spiders']
NEWSPIDER_MODULE = 'crawl_jd.spiders'

DUPEFILTER_CLASS = "scrapy_redis.dupefilter.RPFDupeFilter"
SCHEDULER = "scrapy_redis.scheduler.Scheduler"
SCHEDULER_PERSIST = True


REDIS_HOST= "10.30.56.96"
REDIS_PORT=6379
# Crawl responsibly by identifying yourself (and your website) on the user-agent
#USER_AGENT = 'crawl_jd (+http://www.yourdomain.com)'

# Obey robots.txt rules
# ROBOTSTXT_OBEY = True

# Configure maximum concurrent requests performed by Scrapy (default: 16)
#CONCURRENT_REQUESTS = 32

# Configure a delay for requests for the same website (default: 0)
# See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay
# See also autothrottle settings and docs
DOWNLOAD_DELAY = 2
# The download delay setting will honor only one of:
#CONCURRENT_REQUESTS_PER_DOMAIN = 16
#CONCURRENT_REQUESTS_PER_IP = 16

# Disable cookies (enabled by default)
#COOKIES_ENABLED = False

# Disable Telnet Console (enabled by default)
#TELNETCONSOLE_ENABLED = False

# Override the default request headers:
DEFAULT_REQUEST_HEADERS = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36 SE 2.X MetaSr 1.0'
    ,'cookie': '__jdu=1601890040998551645319; shshshfpa=db02b396-316e-9ea0-404f-d6fd2ea9a085-1601890041; shshshfpb=xHMHQiXN5kRmjMCT8HbWbLw%3D%3D; areaId=13; ipLoc-djd=13-2900-3533-0; unpl=V2_ZzNtbUFSQBImAUNSLEpZBWJQE1oSUhMVdQgWBCxKCFAyBBBbclRCFnQURlVnGFsUZwUZWURcRhdFCEdkeB5fA2AFEFlBZxBFLV0CFi9JH1c%2bbRFbRVBLEnEPR1x%2bKWwGZzMSXHJXRBR1AU5VehxdDW8KFllCUEYRdwhOZEsebDVXARNVQVdLJXQ4R2Q5TQAAZwYQVEEaQxJ0CE9cehhZBG8LG1lGV0QQcQpGXEsYbAY%3d; __jdv=76161171|baidu-search|t_262767352_baidusearch|cpc|27669656094_0_2426b847fb414b06a4a111aafbedd637|1601978262395; PCSYCityID=CN_370000_370800_370811; __jda=122270672.1601890040998551645319.1601890041.1601949708.1601978262.4; __jdc=122270672; 3AB9D23F7A4B3C9B=4F44W5EE2FM3ZZTM3UYDEQRE5NSWE7XVXL4KFCWB2W4X6TZNEQGD6F4FXIF5QT52X3AYVI3HSSXP2AHJSG37TL5WKQ; shshshfp=85e8af86c243fcd5386ba5314bcc933e; wlfstk_smdl=uwc57hw5dcveflaecvrfb4b5tmggnbzi; __jdb=122270672.12.1601890040998551645319|4.1601978262; shshshsID=fb61dd62373fd6e9cc67448688887bd3_4_1601980205014'
,
'referer': 'https://item.jd.com/',
                'sec-fetch-dest': 'script',
                'sec-fetch-mode': 'no-cors',
                'sec-fetch-site': 'same-site',
}


# Enable or disable spider middlewares
# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
#SPIDER_MIDDLEWARES = {
#    'crawl_jd.middlewares.CrawlJdSpiderMiddleware': 543,
#}

# Enable or disable downloader middlewares
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
#DOWNLOADER_MIDDLEWARES = {
#    'crawl_jd.middlewares.CrawlJdDownloaderMiddleware': 543,
#}

# Enable or disable extensions
# See https://docs.scrapy.org/en/latest/topics/extensions.html
#EXTENSIONS = {
#    'scrapy.extensions.telnet.TelnetConsole': None,
#}

# Configure item pipelines
# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
   'crawl_jd.pipelines.CrawlJdPipeline': 300,
}

# Enable and configure the AutoThrottle extension (disabled by default)
# See https://docs.scrapy.org/en/latest/topics/autothrottle.html
#AUTOTHROTTLE_ENABLED = True
# The initial download delay
#AUTOTHROTTLE_START_DELAY = 5
# The maximum download delay to be set in case of high latencies
#AUTOTHROTTLE_MAX_DELAY = 60
# The average number of requests Scrapy should be sending in parallel to
# each remote server
#AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
# Enable showing throttling stats for every response received:
#AUTOTHROTTLE_DEBUG = False

# Enable and configure HTTP caching (disabled by default)
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
#HTTPCACHE_ENABLED = True
#HTTPCACHE_EXPIRATION_SECS = 0
#HTTPCACHE_DIR = 'httpcache'
#HTTPCACHE_IGNORE_HTTP_CODES = []
#HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'
